/// @tags: DP on Tree
#include <cstdio>
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::max;

namespace BlueQuantum {

constexpr int MAXN = 1e2 + 3;

int n, m;
int f[MAXN][MAXN][2];
std::vector<int> e[MAXN];

void dfs(int u, int fa) {
  f[u][0][0] = f[u][0][1] = 1;
  for (auto v : e[u])
    if (v != fa) {
      dfs(v, u);
      for (int j = n; j > 0; --j)
        for (int k = 0; k < j; ++k) {
          if (j - k >= 2) {
            f[u][j][1] = max(f[u][j][1], f[v][k][1] + f[u][j - k - 2][1]);
            f[u][j][0] = max(f[u][j][0], f[v][k][1] + f[u][j - k - 2][0]);
          }
          f[u][j][0] = max(f[u][j][0], f[v][k][0] + f[u][j - k - 1][1]);
        }
    }
  for (int i = 1; i <= n; ++i)
    f[u][i][0] = max(f[u][i][0], f[u][i - 1][0]), f[u][i][1] = max(f[u][i][1], f[u][i - 1][1]);
}

inline int main() {
  cin >> m >> n;
  for (int i = 1, u, v; i < m; ++i) {
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs(0, 0);
  cout << f[0][n][0];
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P3698 [CQOI2017] 小Q的棋盘.in", "r", stdin);
  freopen("P3698 [CQOI2017] 小Q的棋盘.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
